package com.bx.implatform.portal.config;

import com.bx.implatform.portal.interceptor.PortalHeaderInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class PortalRestTemplateConfig {

    @Resource
    PortalProperties portalProperties;

    @Bean("portalRestTemplate")
    public RestTemplate portalRestTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        // 添加签名拦截器（从配置读取appKey和secretKey）
        restTemplate.getInterceptors().add(new PortalHeaderInterceptor(portalProperties.getAppKey(), portalProperties.getAppSecret(), portalProperties.getKey43()));
        return restTemplate;
    }
}
